package com.jida.hadoop.mr.PV;

import com.jida.hadoop.mr.tools.TProperties;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
 
import java.io.IOException;
 
public class PvNumReduce extends Reducer<Text,IntWritable,Text,NullWritable>{
    Text tk = new Text();
 
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int sum = 0;
        for (IntWritable i:values) {
            sum += i.get();
        }
        tk.set(key+TProperties.getValue("outfilesplit")+sum);
        context.write(tk,NullWritable.get());
    }
}
